<template>
  <div id="individual-needs" v-if="info">
    <c-title :text="type == 1 ? '个人需求' : '企业需求'"></c-title>
    <img class="bg-img" :src="type == 1 ? detailData.has_one_category.thumb_url : detailData.has_one_category.thumb_url" alt="" />
    <div class="top-name">
      <div class="name-op">{{ detailData.title }}</div>
      <div class="price-op" v-if="type == 1"><span class="price-sym">￥</span>{{ detailData.service_fee }}</div>
    </div>
    <!-- 发布者 -->
    <div class="content-pane" v-if="type == 1">
      <img class="actor-img" :src="detailData.has_one_publish.avatar_image" alt="" />
      <div class="middle-row">
        <div class="publish-name">
          {{ detailData.has_one_publish.realname }}
          <div class="score-rol">
            <van-icon name="star" class="star-sty" v-for="(item, index) in detailData.has_one_publish.star_grade" :key="item" />
            <span class="score-val">{{ detailData.has_one_publish.star_grade }}分</span>
          </div>
        </div>
        <div class="service-time">
          服务时间 <span class="time-sty">{{ detailData.start_at }}-{{ detailData.finish_time_str }}</span>
        </div>
        <div class="validity-period">信息有效期: {{ detailData.valid_time }}</div>
        <div class="address-sty">
          {{ detailData.order_address.address }}
          <div class="location-sty">
            <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/anytime_service/icon_local (1).png" alt="" class="img-icon" />{{ detailData.distance }}{{ detailData.unit }}
          </div>
        </div>
      </div>
    </div>
    <!-- 企业 -->
    <div class="enterprise-pane" v-if="type == 3">
      <div class="left-row" @click="goEnterpriseInformation">
        <div class="enterprise-name">{{detailData.has_one_enterprise.realname}}</div>
        <div class="enterprise-address">{{detailData.has_one_enterprise.detail_info.corp_address}}</div>
      </div>
      <van-icon name="arrow" class="arrow-sty" />
    </div>
    <div class="content-detail">
      {{ detailData.content }}
      <div class="img-demand" v-if="detailData.pic_url">
        <img :src="detailData.pic_url" alt="" style="max-width: 100%;">
      </div>
    </div>

    <bottom-bar :type="type == 3 ? 'enterprise' : type == 1 ? 'individual' : ''" :order_id="detailData.order_id" :mobile="type == 1 ? `tel:${detailData.has_one_publish.mobile}` : `tel:${detailData.has_one_enterprise.mobile}`"></bottom-bar>
  </div>
</template>
<script>
import individual_needs_controller from "./individual_needs_controller";

export default individual_needs_controller;
</script>
<style lang="scss" rel="stylesheet/scss" scoped>
#individual-needs {
  padding-bottom: 6rem;

  .bg-img {
    height: 16.55rem;
    margin: 0;
    width: 100%;
    object-fit: fill;
  }

  .top-name {
    background: white;
    padding: 0.6rem;

    .name-op {
      font-size: 0.9rem;
      font-weight: 600;
      color: #333;
      line-height: 1;
      text-align: left;
    }

    .price-op {
      margin-top: 0.6rem;
      font-size: 0.85rem;
      font-weight: 500;
      color: #ff9c43;
      line-height: 1;
      text-align: left;

      .price-sym {
        font-size: 0.65rem;
      }
    }
  }

  .content-pane {
    background: white;
    padding: 0.6rem;
    display: flex;
    margin-top: 0.6rem;

    .actor-img {
      width: 2rem;
      height: 2rem;
      border-radius: 50%;
      margin: 0;
    }

    .middle-row {
      margin-left: 0.5rem;
      flex: 5;

      .publish-name {
        font-size: 0.9rem;
        font-weight: bold;
        color: #333;
        text-align: left;
        margin-bottom: 0.3rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
      }

      .service-time {
        font-size: 0.85rem;
        font-weight: 400;
        color: #999;
        text-align: left;

        .time-sty {
          font-size: 0.75rem;
          font-weight: 400;
          color: #ff9c43;
        }
      }

      .validity-period {
        font-size: 0.85rem;
        font-weight: 400;
        color: #ff9c43;
        background: #ffeedf;
        border-radius: 0.1rem 0.1rem 0.1rem 0.1rem;
        padding: 0.2rem 0.3rem;
        margin: 0.4rem 0;
        line-height: 1;
        text-align: left;
        width: fit-content;
      }

      .address-sty {
        text-align: left;
        font-size: 0.85rem;
        font-weight: 400;
        color: #999;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 1;
        display: flex;
        align-items: center;
        justify-content: space-between;
      }
    }

    .score-rol {
      display: flex;
      font-size: 0.9rem;
      align-items: center;
      justify-content: center;
      position: relative;
      top: 0.45rem;

      .star-sty {
        color: #ff9c43;
        margin-right: 0.13rem;
      }

      .score-val {
        color: #ff9c43;
      }
    }

    .location-sty {
      font-size: 0.75rem;
      font-weight: 400;
      color: #999;
      display: flex;
      align-items: center;
      justify-content: flex-end;
      margin-left: 0.1rem;

      img {
        margin-right: 0.2rem;
      }
    }
  }

  .enterprise-pane {
    background: white;
    padding: 0.6rem;
    display: flex;
    margin-top: 0.6rem;
    align-items: center;

    .left-row {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      flex: 5;

      .enterprise-name {
        font-size: 0.85rem;
        font-weight: 400;
        color: #333;
      }

      .enterprise-address {
        font-size: 0.75rem;
        font-weight: 400;
        margin-top: 0.4rem;
        font-size: 0.7rem;
        font-weight: 400;
        color: #999;
      }
    }

    .arrow-sty {
      color: #999;
    }
  }

  .content-detail {
    margin-top: 0.6rem;
    padding: 0.6rem;
    background: white;
    text-align: left;
    font-size: 0.85rem;
  }

  .img-demand {
    margin-top: 0.5rem;
  }

  .img-icon {
    width: 0.85rem !important;
    height: 0.85rem !important;
    margin: 0;
  }
}
</style>
